package com.example.Service;

import com.example.Dao.CommentDao;
    import com.example.Dao.NewsDao;
import com.example.pojo.Comment;
import com.example.pojo.News;

import java.util.List;

public class CommentService {
  CommentDao commentDao =new CommentDao();

  public int addComment(Comment comment){
      return commentDao.addComment(comment);
  }
  public int delComment(int id){
      return commentDao.deleteComment(id);
  }

  //获取总行数
    public int getTotalByNewsId(int id){
      return commentDao.getTotalByNewsId(id);
    }
  public List<Comment> getAllCommentByNewsId(int newsid,String userId){
      return  commentDao.getCommentByNewsId(newsid ,userId);
  }
  public Comment getCommentById(int id){
    Comment n= commentDao.getCommentById(id);
    return  n;
  }
  public int addLikeComment(int commentId,String userId){

      return commentDao.addLikeComment(commentId,userId);
  }
    public List<Comment> getCommentByNewsId(int newsId, String userId) {
        return commentDao.getCommentByNewsId(newsId, userId);
    }

    // 原有方法保留（兼容其他场景）

    // 新增：查询当前用户是否已点赞某评论
    public boolean isLiked(int commentId, String userId) {
        return commentDao.findIslike(commentId, userId) > 0;
    }
}
